﻿using System;
using System.IdentityModel.Selectors;
using System.ServiceModel;
using EFRepository;
using ServerServices;

namespace ConsoleHost
{
    public class CustomUserNameValidator : UserNamePasswordValidator
    {
        public ManagerRepository Repository { get; set; }

        public override void Validate(string userName, string password)
        {
            if (null == userName || null == password)
            {
                throw new ArgumentNullException();
            }

            if (Repository.GetUser(userName, password) == null)

                throw new FaultException<ServiceFault>(new ServiceFault("Invalid user"));
        }
    }
}